let usernameEle = document.getElementsByClassName('username')[0]
let passwordEle = document.getElementsByClassName('password')[0]
let btnEle = document.getElementsByClassName('btn')[0]

btnEle.onclick=()=>{
  let username = usernameEle.value
  let password = passwordEle.value

  if(!checkUsername(username)){

    alert('用户名不符合要求')
  }else if(!checkPassword(password)){
    alert('密码不符合要求')
  }else{

    $.ajax({
      type:'get',
      url:'http://localhost:3000/user/userLogin',
      data:{ username,password },
      success:(result)=>{

        if(result.status === 'success'){
          location.href=`/user/info?id=${result.id}`
        }else{
          alert(result.message)
        }
      }
    })
  }
}